package com.ck.express.activity

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.ck.express.R
import com.ck.express.adapter.RecordPagerAdapter
import com.ck.express.databinding.ActivityOperationRecordBinding
import com.google.android.material.tabs.TabLayoutMediator

class OperationRecordActivity : AppCompatActivity() {

    private lateinit var binding: ActivityOperationRecordBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityOperationRecordBinding.inflate(layoutInflater)
        setContentView(binding.root)

        setupToolbar()
        setupViewPager()
    }

    private fun setupToolbar() {
        binding.toolbar.setNavigationOnClickListener { onBackPressed() }
    }

    private fun setupViewPager() {
        val adapter = RecordPagerAdapter(this)
        binding.viewPager.adapter = adapter

        // 绑定 TabLayout 和 ViewPager
        TabLayoutMediator(binding.tabLayout, binding.viewPager) { tab, position ->
            tab.text = when (position) {
                0 -> getString(R.string.tab_delivery_failed)
                1 -> getString(R.string.tab_lattice_failed)
                else -> ""
            }
        }.attach()
    }
}